<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>新增项目</title>
<base href="<%=basePath%>" />
<%@ include file="../../cuv_include.jsp"%>
<style type="text/css">
fieldset {
	margin: 10px;
	padding: 10px;
	width: 90%;
}
select {
	width: 100%;
	height: 200px;
}
#mak1,#mak2,#mak3,#dev1,#dev2,#dev3,#test1,#test2,#test3 {
	float: left;
}
#mak1,#dev1, #test1{
	width: 30%;
	float: left;
}
#mak3,#dev3,#test3 {
	width: 30%;
	float: right;
}
#mak2,#dev2,#test2{
	width: 20%;
	padding-left: 10%;
}
.btn {
	display: block;
	margin: 10px auto;
	width: 60px;
}
</style>
<script type="text/javascript">  
	    $(document).ready(function(){
	        var options = {dataType: 'json', success: process};
	        $("#confForm").submit(function(){
	        	var arrayObj = new Array();
	        	var srcOptions;
	        	srcOptions = null;
	        	arrayObj = new Array();
	            srcOptions = $("#devPerson option");
	            $(srcOptions).each(function(){
	                arrayObj.push($(this).attr("value"));
	            });
	            var devenname = arrayObj.join(";");
	        	$("#devenname").val(devenname);
	        	
	        	srcOptions = null;
	        	arrayObj = new Array();
	            srcOptions = $("#testPerson option");
	            $(srcOptions).each(function(){
	                arrayObj.push($(this).attr("value"));
	            });
	            var testenname = arrayObj.join(";");
	        	$("#testenname").val(testenname);
	        	
	            $(this).ajaxSubmit(options);
	            return false;
	        });      
	    });
	    
	    /*右移   */
        function Move(src, dest) {
            var srcOptions = $("#"+ src +" option:selected");  
            $(srcOptions).each(function(){
                $(this).removeAttr("selected");
            });
            $(srcOptions).remove();
            $("#"+dest).append(srcOptions);
        }   
        /*左移  */
        function leftMove(src) {
            var srcOptions = $("#"+ src +" option:selected");  
            $(srcOptions).each(function(){
                $(this).removeAttr("selected");
                $(this).remove();
                $("#"+this.id).append(this);
            });
        }   
    	
        /* 全部左移 */
        function leftMoveAll(src) {
        	var srcOptions = $("#"+ src +" option");
            $(srcOptions).each(function(){
            	$(this).removeAttr("selected");
                $(this).remove();
                $("#"+this.id).append(this);
            });    
        }
        
        /* 全部右移 */
        function MoveAll(src, dest) {
        	var srcOptions = $("#"+ src +" option");
            $(srcOptions).each(function(){
                $(this).removeAttr("selected");
            });
            $(srcOptions).remove();
            $("#"+dest).append(srcOptions);            
        }

        function process(responseJson) {
	        if(responseJson.code == 0) {
	            $('#error_label').text("错误信息：" + responseJson.message);
	            $("#p_error").show();
	            return;
	        }
	        var qs = $("#qs").val();
	        location.href = "<%=basePath%>soft/project/list.do?" + qs;
        }  
        //返回列表页面
        function btn_return(){
            var qs = $("#qs").val();
        	window.location.href="<%=basePath%>soft/project/list.do?" + qs;
	    }
</script>
</head>
<body>
	<div style="float:left;width:60%">
	<fieldset>
			<legend>开发人员：</legend>
			<input id="qs" name="qs" type="hidden" value="${qs}"/>
	     	<p id = "p_error" style = "margin:10px 10px;">
	     	    <label id="error_label" style="color:red;"></label>
	     	</p>
			<div id="dev1">
				<select  size="15" multiple="multiple">
					<c:forEach var="dept" items="${allDeptList}" varStatus="status">
						<optgroup label="${dept.deptName}" id="${dept.deptNo}${'unSelected0'}">
							<c:forEach var="user" items="${unDevUsers}" varStatus="status">
								<c:if test="${user.deptNo == dept.deptNo}">
									<option id="${user.deptNo}${'unSelected0'}"  value="${user.enname}">${user.cnname}</option>
								</c:if>
							</c:forEach>
						</optgroup>
					</c:forEach>
				</select>
			</div>
			<div id="dev2">
				<input type="button" value="&gt;" class="btn"
					onclick="${devUnToSelect}"/> 
				<input type="button" value="&gt;&gt;" class="btn"
					onclick="${devAllUnToSelect}"/>
				<input type="button" value="&lt;" class="btn"
					onclick="${devSelectedToUn}" /> 
				<input type="button" value="&lt;&lt;" class="btn"
					onclick="${devAllSelectedToUn}"/>
			</div>
			<div id="dev3">
				<select id="devPerson" name="devPerson" size="15"multiple="multiple">
						<optgroup label="开发人员" id="selected0">
							<c:forEach var="user" items="${selectedDevUsers}" varStatus="status">
									<option id="${user.deptNo}${'unSelected0'}" value="${user.enname}">${user.cnname}</option>
							</c:forEach>
						</optgroup>
				</select>
			</div>
		</fieldset>
	</div>
    <div style="float:left;width:60%">
	<fieldset>
			<legend>测试人员：</legend>
			<div id="test1">
				<select id="allPerson" name="allPerson" size="15" multiple="multiple">
					<c:forEach var="dept" items="${allDeptList}" varStatus="status">
						<optgroup label="${dept.deptName}" id="${dept.deptNo}${'unSelected2'}">
							<c:forEach var="user" items="${unTestUsers}" varStatus="status">
								<c:if test="${user.deptNo== dept.deptNo}">
									<option id="${user.deptNo}${'unSelected2'}"  value="${user.enname}">${user.cnname}</option>
								</c:if>
							</c:forEach>
						</optgroup>
					</c:forEach>
				</select>
			</div>
			<div id="test2">
				<input type="button" value="&gt;" class="btn"
					onclick="${testUnToSelect}"/> 
				<input type="button" value="&gt;&gt;" class="btn"
					onclick="${testAllUnToSelect}"/>
				<input type="button" value="&lt;" class="btn"
					onclick="${testSelectedToUn}" /> 
				<input type="button" value="&lt;&lt;" class="btn"
					onclick="${testAllSelectedToUn}"/>
			</div>
			<div id="test3">
				<select id="testPerson" name="testPerson" size="15"multiple="multiple">
						<optgroup label="测试人员" id="selected2">
							<c:forEach var="user" items="${selectedTestUsers}" varStatus="status">
									<option id="${user.deptNo}${'unSelected2'}" value="${user.enname}">${user.cnname}</option>
							</c:forEach>
						</optgroup>
				</select>
			</div>
			<div style="clear: both;"></div>
			<div style="margin-top: 10px;">
				<form id="confForm" action="soft/project/personConf.do" method="post">
					 <input type="hidden" name="projectId" id="projectId" value="${projectId}" />
					 <input type="hidden" name="makenname" id="makenname" /> 
					 <input type="hidden" name="devenname" id="devenname" /> 
					 <input type="hidden" name="testenname" id="testenname" /> 
					 <input type="submit" value="提交" style="width: 80px;" />
					 <input id="btn_back" type="button" value="返回" onclick="btn_return();" style="width: 80px;" />
					 <span style="color: red;">(提示:按住Ctrl或Shift可以多选!)</span>
				</form>
			</div>
	</fieldset>
    </div>
</body>
</html>